package com.lagouedu.controller;

import com.lagouedu.filter.MethodTakeTime;
import com.lagouedu.service.DubboMointerService;
import com.lagouedu.service.RunTestMontiorService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;

@RestController
public class TestMoniterController {

    @Reference
    private DubboMointerService dubboMointerService;

    @Autowired
    private RunTestMontiorService runTestMontiorService;

    @RequestMapping("/testMonitor")
    public Map testMonitor(){
        Map map = new HashMap();

        for(int i = 0; i < 2000; i ++){
//            System.out.println("-----------第" + i + "次--------------");
            runTestMontiorService.doRunMethods();
        }

//        for(int i = 0; i < 1; i ++){
//            // 获取线程 分别调用 3个方法
//            monitorExecutor.execute(new Runnable() {
//                @Override
//                public void run() {
//                    dubboMointerService.methodA();
//                }
//            });
//            monitorExecutor.execute(new Runnable() {
//                @Override
//                public void run() {
//                    dubboMointerService.methodB();
//                }
//            });
//            monitorExecutor.execute(new Runnable() {
//                @Override
//                public void run() {
//                    dubboMointerService.methodC();
//                }
//            });
//        }

        return map;
    }
}
